package cj.web.admin.dao;

import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.ReportCard;

/**
 * 
 * @author 
 *
 */
@DAO
public interface ReportCardDAO{
	
	@SQL("SELECT * FROM ReportCard WHERE gameId=:t.gameId #if(:t.code!=''){ AND code LIKE '%##(:t.code)%' } #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } LIMIT :t.start,:t.length ")
    List<ReportCard> query(@SQLParam("t") ReportCard reportCard);
	
	@SQL("SELECT count(1) FROM ReportCard WHERE gameId=:t.gameId #if(:t.code!=''){ AND code LIKE '%##(:t.code)%' } #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } ")
    int querysize(@SQLParam("t") ReportCard reportCard);
	
	@SQL("select count(1) from ReportCard where gameId=:1 and code=:2")
    int querySizeByCode(int gameId,String code);
	
	@SQL("SELECT * FROM ReportCard WHERE gameId=:1")
    List<ReportCard> queryReportCardByGameId(int gameId);
    
    @SQL("select * from ReportCard where id=:1")
    ReportCard queryById(int id);
    
    @SQL("INSERT INTO ReportCard (gameId,code,level,name,teacher,school,grade,parentName,parentPhone,path,payStatus,area,th) VALUES (:t.gameId,:t.code,:t.level,:t.name,:t.teacher,:t.school,:t.grade,:t.parentName,:t.parentPhone,:t.path,:t.payStatus,:t.area,:t.th)")
    void create(@SQLParam("t") ReportCard reportCard);
	
	@SQL("UPDATE ReportCard SET payStatus=:t.payStatus,gameId=:t.gameId,code=:t.code,level=:t.level,name=:t.name,teacher=:t.teacher,school=:t.school,grade=:t.grade,parentName=:t.parentName,parentPhone=:t.parentPhone,path=:t.path,area=:t.area,th=:t.th WHERE id=:t.id")
    void update(@SQLParam("t") ReportCard reportCard);
    
    @SQL("UPDATE ReportCard SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE ReportCard SET payStatus=1 WHERE id=:1")
    void updatePayStatusById(int id);
    
    @SQL("UPDATE ReportCard SET path=:2 WHERE id=:1")
    void updatePathStatusById(int id,String path);
}